﻿@model AccountModel

@{
    ViewBag.Title = "个人信息设置 - 小博客";
    Layout = "~/Views/Shared/_BlogLayout.cshtml";
}
<link href="~/Content/Blog/userInfo.css" rel="stylesheet" />
<script src="~/Scripts/mailAutoComplete.js"></script>
<div style="padding:5px">
    <div id="utabs" class="tab-container">
        <ul class='etabs'>
            <li class='tab'><a href="#tab1">基本信息</a></li>
            <li class='tab'><a href="#tab2">安全设置</a></li>
        </ul>
        <div class="panel-container">
            <div id="tab1">
                <div class="dvinfohead">个人信息</div>
                <table>
                    <tr>
                        <td><label class="lbw">帐号：</label></td>
                        <td><input id="account" name="account" class="inputbox" type="text" disabled="disabled" value="@Model.Account" /></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><label class="lbw">昵称：</label></td>
                        <td><input class="inputFilter inputbox" id="nickname" maxlength="20" name="nickname" type="text" value="@Model.NickName" /></td>
                        <td rowspan="5" style="text-align:center; width:200px;">
                            <div style="border-left:solid 1px #e2e4de;padding-top:2px;">
                                <div style="clear:both; width:100%;">
                                    <div title="正在上传头像，请稍候" id="showload" style="display:none;width:145px;height:125px; line-height:125px; margin:0 auto; cursor:pointer;border:1px solid #e2e4de;"><img src="~/Content/Images/loading.gif" /></div>
                                    <img id="imgHead" style="width:145px;height:125px; cursor:pointer;border:1px solid #e2e4de;" title="点击修改头像" onclick="showSelect()" />
                                    <div id="divShow" title="点击修改头像" onclick="showSelect()" style="border:1px solid;display:none; cursor:pointer; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);width:145px;height:125px">
                                    </div>
                                </div>
                                <div style="clear:both;width:100%;">
                                    <input type="button" id="btnUpload" class="btnNormal" value="修改头像" onclick="showSelect()" />
                                    <input type="file" id="headfile" name="file" style="display:none" onchange="upload(this)" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td><label class="lbw">姓名：</label></td>
                        <td><input id="uname" class="inputFilter inputbox" maxlength="20" name="username" type="text" value="@Model.UserName" /></td>
                    </tr>
                    <tr>
                        <td><label class="lbw">性别：</label></td>
                        <td>
                            <select style="width:176px" id="sex">
                                <option value="0" @(Model.Sex.Value ? "selected='selected'" : "" )>男</option>
                                <option value="1" @(!Model.Sex.Value ? "selected='selected'" : "" )>女</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td><label class="lbw">生日：</label></td>
                        <td><input id="birthday" name="birthday" class="datePicker inputbox" value="@(Model.Birthday.HasValue?Model.Birthday.Value.ToString("yyyy-MM-dd"):"")" readonly="readonly" type="text" /></td>
                    </tr>
                    <tr>
                        <td><label class="lbw">专业：</label></td>
                        <td><input id="profession" class="inputFilter inputbox" maxlength="20" name="profession" type="text" value="@Model.Profession" /></td>
                    </tr>
                    <tr>
                        <td><label class="lbw">学历：</label></td>
                        <td>
                            <select id="edu" style="width:176px">
                                <option value="未知">请选择</option>
                                <option value="小学">小学</option>
                                <option value="初中">初中</option>
                                <option value="高中">高中</option>
                                <option value="大专">大专</option>
                                <option value="本科">本科</option>
                                <option value="硕士">硕士</option>
                                <option value="博士">博士</option>
                            </select>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><label class="lbw">Email：</label></td>
                        <td><input id="email" class="inputFilter inputbox" name="email" type="text" value="@Model.Email" /><label id="lbemail" class="red padd5">(注：暂不支持修改Email绑定)</label></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><label class="lbw">博客模版：</label></td>
                        <td>
                            <select style="width:176px" id="template">
                                <option value="boy" @(Model.IsBoyTemplate ? "selected='selected'" : "" )>男生模版</option>
                                <option value="girl" @(!Model.IsBoyTemplate ? "selected='selected'" : "" )>女生模版</option>
                            </select>
                            <a class="green" href="javascript:;" onclick="showView()">查看预览图</a>
                        </td>
                    </tr>
                    <tr>
                        <td><label class="lbw">所属区域：</label></td>
                        <td>
                            <select id="province" class="selexm"></select>
                            <select id="city" class="sellong"></select>
                            <select id="county" class="sellong"></select>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><label class="lbw">详细地址：</label></td>
                        <td><input id="address" class="inputFilter inputbox" type="text" maxlength="50" /></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><label class="lbw">最爱一句话：</label></td>
                        <td colspan="2">
                            <input id="motto" class="inputFilter inputbox" maxlength="50" name="motto" type="text" value="@Model.Motto" />
                            <label class="green">(这句话将显示在您的主页上，最多50个字)</label>
                        </td>
                    </tr>
                    <tr>
                        <td><label class="lbllast">关于我：</label></td>
                        <td colspan="2"><textarea id="profile" style="width:100%; height:200px;"></textarea><input type="hidden" value="@Model.PersonalProfile" id="hProfile" /></td>
                    </tr>
                    <tr>
                        <td colspan="3" style="height:45px; text-align:center;"><input class="btnsubmit" type="button" id="btnSave" value="保存" /></td>
                    </tr>
                </table>
            </div>
            <div id="tab2">
                <form id="frmpwd">
                    <div class="dvinfohead">修改密码</div>
                    <div class="dv-normal"><span>原密码：</span><input id="passOld" name="passOld" type="password" maxlength="16" class="inputbox" /><label id="spold" class="red"></label></div>
                    <div class="dv-normal"><span>新密码：</span><input id="pass" name="pass" type="password" maxlength="16" class="inputbox" /><label class="red" id="sppwd"></label></div>
                    <div class="dv-normal"><span> 确认新密码：</span><input id="pass2" name="pass2" type="password" maxlength="16" class="inputbox" /><label id="sppwd2" class="red"></label></div>
                    <div class="dv-btn"><input type="button" class="btnsubmit" value="修改" onclick="mpass()" /></div>
                </form>
            </div>
        </div>
    </div>
</div>

@{
    string province = "请选择", city = "请选择", country = "请选择", address = "";
    if (!string.IsNullOrWhiteSpace(Model.Native) && Model.Native.Contains("-"))
    {
        var add = Model.Native.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
        switch (add.Length)
        {
            case 2:
                province = add[0];
                city = add[1];
                break;
            case 3:
                province = add[0];
                city = add[1];
                country = add[2];
                break;
            default:
                if (add.Length > 3)
                {
                    province = add[0];
                    city = add[1];
                    country = add[2];
                    address = add[3];
                }
                else
                {
                    province = add[0];
                }
                break;
        }
    }
}
<script src="~/Scripts/jedate/jedate.js"></script>
<script src="~/Scripts/ajaxfileupload.js"></script>
<script src="~/Scripts/Blog/userinfo.js"></script>
<script type="text/javascript">
    $(function () {
        $('#edu').val($.trim('@Model.Education'));
        $('#province').val('@province');
        $('#province').change();
        $('#city').val('@city');
        $('#city').change();
        $('#county').val('@country');
        $('#address').val('@address');
    })
</script>
